/*
 * @Author: hyq
 * @LastEditors: hyq
 * @Description:
 * type 设置可选参数
 * @Date: 2023-12-11 18:13:20
 */
interface info {
  title: string
  content: string
}

export type Optional1<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>

const createAnimate = (options) => {
  var from = options.from; // 起始值
  var to = options.to; // 结束值
  var totalMS = options.totalMS || 1000; // 总时间
  var duration = options.duration || 15; // 每多少时间变化一次
  
  var times = Math.floor(totalMS / duration); // 变化次数
  var dis = (to - from) / times; // 每次变量化

  var curIndex = 0; // 当前变化次数
  const timeId = setInterval(() => {
    from += dis;
    curIndex++;
    if (curIndex >= times) {
      from = to;
      clearInterval(timeId);
      options.onend && options.onend();
    }
    options.onmove && options.onmove(from);
  }, duration);
}